package Simulation;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

import Simulation.Gem.GemType;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.me.mynanogame.StaticSprites;

public class Simulation {
	public ArrayList<Gem> gems;
	public ArrayList<Gem> activeGems;
	public int numberOfGems;
	public Sprite[] gemSprites;
	public boolean simulated;
	
	public Simulation(){
		activeGems = new ArrayList<Gem>();
		gems = new ArrayList<Gem>();
		simulated = false;
		gemSprites = new Sprite[126];
		randomizeGems();
	}
	
	public void simulate(ArrayList<Player> players, int ngems, int hiddengems){
		numberOfGems = ngems;
		for(int i = 0; i < numberOfGems; i++){
			activeGems.add(gems.get(i));
			gems.remove(i);
		}
		simulated = true;
	}
	
	public void clearActiveGems(){
		activeGems.clear();
		numberOfGems = 0;
	}
	
public void initGems(){
		for(int i = 0; i<35; i++){
			gems.add(new Gem(GemType.SILVER));
		}
		for(int i = 0; i<20; i++){
			gems.add(new Gem(GemType.GOLD));
		}
		for(int i = 0; i<16; i++){
			gems.add(new Gem(GemType.RED));
		}
		for(int i = 0; i<12; i++){
			gems.add(new Gem(GemType.GREEN));
			gems.add(new Gem(GemType.BLUE));
			gems.add(new Gem(GemType.PURPLE));
			gems.add(new Gem(GemType.YELLOW));
		}
		for(int i = 0; i<6; i++){
			gems.add(new Gem(GemType.WHITE));
		}
		gems.add(new Gem(GemType.BLACK));

	}
	
	public void randomizeGems(){
		initGems();
		long seed = System.nanoTime();
		Collections.shuffle(gems, new Random(seed));
	}	
}
